<template>
  <div>
    <el-dialog
      @closed="resetForm"
      title="题目审核"
      :visible="isVisible"
      @update:visible="$emit('update:isVisible', $event)"
      width="400px"
      :before-close="handleClose">
      <el-form
        :model="dataForm"
        :rules="rules"
        ref="dataForm">
        <el-form-item prop="chkState">
          <el-radio-group v-model="dataForm.chkState">
            <el-radio :label="1">通过</el-radio>
            <el-radio :label="2">拒绝</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item prop="chkRemarks">
          <el-input type="textarea" v-model="dataForm.chkRemarks"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="$emit('update:isVisible', false)">取消</el-button>
          <el-button @click="onConfirm">确认</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { checkQuestion } from '@/api/querstionbank'
export default {
  name: 'CheckDialog',
  props: {
    isVisible: Boolean,
    passId: Number,
    isAdd: Boolean,
  },
  data() {
    return {
      dataForm: {
        chkState: 1,
        chkRemarks: ''
      },
      rules: {
        chkState: {},
        chkRemarks: {}
      }
    }
  },

  methods: {
    handleClose(done) {
      return done()
    },
    resetForm() {
      this.$refs.dataForm.resetFields();
    },
    async onConfirm() {
      const res = await checkQuestion(this.passId, {
        ...this.dataForm,
        id: this.passId
      })
      console.log(res)
      this.$emit('success')
      this.$emit('update:isVisible', false)
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
